CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
option(BUILD_QDS_COMPONENTS "Build design studio components" ON)

# 导入 Qt 模块
find_package(Qt6 COMPONENTS Core Quick Qml Gui REQUIRED)

# 设置Qt相关的变量
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)         # 资源文件处理
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# 添加头文件
include_directories(../include)
include_directories(./include)

file(GLOB_RECURSE SRC_LIST *.cpp *.h)

# 添加可执行文件
qt6_add_executable(${IMG_VIEWER_APP_NAME} WIN32 ${SRC_LIST})
qt_finalize_executable(${IMG_VIEWER_APP_NAME})

# 链接 Qt 库
target_link_libraries(${IMG_VIEWER_APP_NAME} PRIVATE
    Qt6::Core
    Qt6::Quick
    Qt6::Qml
    Qt6::Gui
    ${LIBRARY_NAME}
)

qt6_add_resources(${IMG_VIEWER_APP_NAME} "configuration"
    PREFIX "/"
    FILES
        qtquickcontrols2.conf
)

set(QML_IMPORT_PATH ${QT_QML_OUTPUT_DIRECTORY}
    CACHE STRING "Import paths for Qt Creator's code model"
    FORCE
)

if (BUILD_QDS_COMPONENTS)
    include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents)
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules)

# make IDEs aware of the QML import path
set(QML_IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml CACHE PATH
    "Path to the custom QML components defined by the project")